package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.BatchFlowBillEntity;
import com.xbongbong.saas.domain.entity.BatchFlowBillEntityExt;
import com.xbongbong.saas.domain.entity.BatchFlowBillUpdateEntity;
import com.xbongbong.saas.domain.entity.StockFlowBillEntity;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface BatchFlowBillModel extends IModel<BatchFlowBillEntity> {
    /**
     * 入库单产品数据插入
     * @param batchFlowBillEntity 供应商实体
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     * @return Integer
     */
    Integer insert(BatchFlowBillEntity batchFlowBillEntity) throws XbbException;
    /**
     * 入库单产品数据更新
     * @param batchFlowBillEntity 供应商实体
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     * @throws XbbException 异常
     * @return Integer
     */
    Integer update(BatchFlowBillEntity batchFlowBillEntity) throws XbbException;

    /**
     * 根据索引查询数据
     *
     * @param param 查询参数
     * @author lee
     * @date 2020/1/13 16:51
     * @since v1.0
     * @version v1.0
     * @return List<ProductEntityExt>
     **/
    List<BatchFlowBillEntity> findEntitys(Map<String, Object> param);

    /**
     * 查询列表数量
     *
     * @param param
     * @return Integer
     * @author lee
     * @date 2020/4/13 16:07
     * @descption
     */
    Integer getEntitysCount(Map<String, Object> param);

    Integer save(BatchFlowBillEntity batchFlowBillEntity);

    void insertBatch(List<BatchFlowBillEntity> batchFlowBillEntityList) throws XbbException;

    /**
     * 更新单个单据日期后的库存和成本
     * @param corpid
     * @param batchKeyList
     * @return
     */
    Integer updateGreaterThanTime(Collection<BatchFlowBillUpdateEntity> updateList, String corpid, Set<String> batchKeyList);

    /**
     * 获取筛选时间内最新的结存记录
     * @param corpid
     * @param batchKeySet
     * @param dateTime
     * @return
     */
    List<BatchFlowBillEntity> getLatestFlowBillByBatchKey(String corpid, Set<String> batchKeySet, Long dateTime);


    /**
     * 获取筛选
     * @param corpid
     * @return
     */
    List<String> getLatestDistinctBatch(String corpid, String batchLike);

    Integer deleteByRefIdIn(String corpid, List<Long> refIdIn, List<Integer> businessTypeIn);

    /**
     * 获取期间的出入库汇总信息
     * @param param
     * @return
     */
    List<BatchFlowBillEntityExt> getFlowInfo(Map<String, Object> param);

    /**
     * 查询分组后计数
     *
     * @param param
     * @return Integer
     * @author lee
     * @date 2020/4/13 16:07
     * @descption
     */
    Integer getGroupByEntitysCount(Map<String, Object> param);

    void updateBatch(Collection<BatchFlowBillUpdateEntity> updateList, String corpid, Set<String> warehouseKeyList);

    void deleteAllByCorpId(String corpid);

    void updateBatchByParentId(String corpid, Long parentId, Integer visible);

    List<BatchFlowBillEntity> queryBatchFlowbydate(Map<String, Object> param);

    void updateBatchFlowById(List<BatchFlowBillEntity> batchFlowBillEntityList, String corpid);

    List<BatchFlowBillEntity> queryBatchFlowbydateAndId(String corpid, Long data, List<Long> productId);

    void deleteByAddTime(Map<String, Object> param);

    List<BatchFlowBillEntity> getBatchFlowByBatchKey(String corpid, List<String> batchKeyList);

    BatchFlowBillEntity getBatchFlowBillBytime(String corpid, Long productId, Long warehouseId, String batchKey);
}
